Skip to content

fix: add monthly budget support to dashboard#364

Merged
bicced merged 2 commits intomainfrom
fix/dashboard-monthly-budget
Mar 7, 2026
Merged

fix: add monthly budget support to dashboard#364
bicced merged 2 commits intomainfrom
fix/dashboard-monthly-budget

Conversation

@LegionInterns
Copy link
Collaborator

Problem

The dashboard budget endpoints only handled daily_usd, silently resetting monthly_usd to the $200 default on every update. This meant any custom monthly budget was lost whenever the daily budget was changed.

Root Cause

CostTracker.set_budget() takes both daily_usd and monthly_usd with defaults, but both dashboard endpoints only passed daily_usd, so monthly_usd always reset to 200.0.

Fix

  • PUT /api/agents/{id}/budget: Accept optional monthly_usd, read current budget before updating so the other limit is preserved
  • PUT /api/agents/{id} (general edit): Same treatment for the budget field
  • Dashboard JS: Add budget_monthly to edit form, send both values to API
  • Dashboard HTML: Add monthly budget input field next to the daily one

Testing

  • Verified bug: set_budget(agent, daily_usd=100) resets monthly to $200
  • Verified fix: both endpoints now preserve the untouched limit
  • Cost tracker tests pass (20/20)

LegionInterns and others added 2 commits March 7, 2026 08:39
The dashboard budget endpoints only handled daily_usd, silently resetting
monthly_usd to the $200 default on every update. This meant any custom
monthly budget was lost whenever the daily budget was changed.

Fix:
- api_update_budget: accept optional monthly_usd, preserve current value
  when not provided
- agent edit endpoint: same treatment for the budget field
- Dashboard JS: add budget_monthly to edit form, send both values
- Dashboard HTML: add monthly budget input field

Both endpoints now read the current budget before calling set_budget()
so updating one limit doesn't reset the other.
The try/float()/> 0/except pattern was duplicated 4 times across the two
budget endpoints. Extracted into a single module-level helper that
validates, converts, or falls back to the current value.
@bicced bicced merged commit 2c6fa1e into main Mar 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants